using System;
using System.Collections.Generic;
using System.Text;
using jstm.generator;

namespace Sample1Generator
{
	class Program
	{
		public static ObjectModelDefinition create()
		{
			ObjectModelDefinition model = new ObjectModelDefinition( "Sample1ObjectModel" );

			Package pack = new Package( "Generated" );
			model.RootPackage = pack;

			Structure simple = new Structure( "SimpleStructure" );
			simple.Fields.add( new Field( typeof( string ), "Text" ) );
			simple.Fields.add( new Field( typeof( int ), "Int" ) );
			simple.Fields.add( new Field( typeof( double ), "Double" ) );
			simple.Fields.add( new Field( simple, "Entity" ) );

			Method query = new Method( "query" );
			query.ReturnValue = new ReturnValue( typeof( string ) );
			query.Arguments.add( new Argument( typeof( string ), "sql" ) );
			query.Arguments.add( new Argument( simple, "eg" ) );
			simple.Methods.add( query );

			pack.Structures.add( simple );

			return model;
		}

		static void Main( string[] args )
		{
			ObjectModelDefinition model = create();
			Generator generator = new Generator( model );
			generator.writeFiles( @"..\..\..\Sample1Server", Generator.Target.CSharp, false );

			Console.WriteLine( "" );
			Console.WriteLine( "Success!" );
			Console.ReadLine();
		}
	}
}
